import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import vuescroll from 'vuescroll/dist/vuescroll-native';
import axios from "axios";
import api from './request/api';
import { post, get, upPic } from './request/http';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import VueTouchKeyboard from "vue-touch-keyboard";
import AlloyFinger from "alloyfinger";
import AlloyFingerPlugin from 'alloyfinger/vue/alloy_finger_vue'
import VueAwesomeSwiper from 'vue-awesome-swiper'
import 'swiper/swiper-bundle.css'


Vue.config.productionTip = false;

Vue.prototype.axios = axios;
Vue.prototype.api = api;
Vue.prototype.post = post;
Vue.prototype.get = get;
Vue.prototype.upPic = upPic;

Vue.use(ElementUI);
Vue.use(VueAwesomeSwiper)
Vue.use(vuescroll);
Vue.use(VueTouchKeyboard);
Vue.use(AlloyFingerPlugin, {
    AlloyFinger
})
Vue.filter('formatDate', function (str) {
    if (!str) return ''
    var date = new Date(str)
    var time = new Date().getTime() - date.getTime() //现在的时间-传入的时间 = 相差的时间（单位 = 毫秒）
    if (time < 0) {
        return ''
    } else if ((time / 1000 < 30)) {
        return '刚刚'
    } else if (time / 1000 < 60) {
        return parseInt((time / 1000)) + '秒前'
    } else if ((time / 60000) < 60) {
        return parseInt((time / 60000)) + '分钟前'
    } else if ((time / 3600000) < 24) {
        return parseInt(time / 3600000) + '小时前'
    } else if ((time / 86400000) < 31) {
        return parseInt(time / 86400000) + '天前'
    } else if ((time / 2592000000) < 12) {
        return parseInt(time / 2592000000) + '月前'
    } else {
        return parseInt(time / 31536000000) + '年前'
    }
});
Vue.prototype.$vuescrollConfig = {
    mode: 'slide',
    bar: {
        background: '#e59243',
        size: '12px',
        onlyShowBarOnScroll: false,
        showDelay: 500
    },
    rail: {
        gutterOfSide: '10px',
    }
};

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount("#app");
